import 'package:flutter/material.dart';

class BadgeBottomNavigationBarItem extends StatelessWidget {
  final BottomNavigationBarItem item;
  final int? badgeValue;

  const BadgeBottomNavigationBarItem({
     key,
    required this.item,
    this.badgeValue,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Stack(
      alignment: Alignment.center,
      children: [
        item.icon,
        Positioned(
          top: 0,
          right: 0,
          child: Container(
            padding: const EdgeInsets.all(2),
            decoration: BoxDecoration(
              color: Colors.red,
              borderRadius: BorderRadius.circular(10),
            ),
            constraints: const BoxConstraints(
              minWidth: 20,
              minHeight: 20,
            ),
            child: Text(
              badgeValue.toString(),
              style: const TextStyle(
                color: Colors.red,
                fontSize: 12,
              ),
              textAlign: TextAlign.center,
            ),
          ),
        ),
      ],
    );
  }
}
